package com.zch.math_;

public class MathMethod {
    public static void main(String[] args) {
        System.out.println(Math.abs(-3));   //3

        double a=Math.pow(2,4);    //16

        double res=Math.ceil(-3.1); //ceil 向上取整
        System.out.println(res);   //-3.0

        double res1=Math.floor(-3.3); //floor 向下取整
        System.out.println(res1);  //-4

        double c=Math.sqrt(4);
        System.out.println(c);

        int res3=Math.max(3,4);
        System.out.println(res3);

        double res4=Math.min(3.3,-1.0);
        System.out.println(res4);

        long res2=Math.round(-3.3); //round 四舍五入
        System.out.println(res2);

        System.out.println("=======================");
        for (int i = 0; i < 5; i++) {
            System.out.println(Math.random());
        } //random 返回[0,1)之间的一个随机小数

        System.out.println("=======================");
        for (int i = 0; i < 5; i++) {
            System.out.println((int)(2 + Math.random() * 6));
        } //返回[2,7]之间的随机整数


    }
}
